package com.srd.phone.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.shengrongdai.srd.R;
import com.srd.phone.application.HttpStringRequest;
import com.srd.phone.utils.Constants;
import com.srd.phone.utils.LogUtils;
import com.srd.phone.utils.PreferenceUtils;
import com.srd.phone.utils.UserUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 债权转让详情
 */
public class TenderZqInvestActivity extends BaseActivity implements  View.OnClickListener {

    private TextView tv_zq_people;//债权所属人
    private TextView tv_start_money; //原始债权金额
    private TextView tv_zq_tender_time; //标的期限
    private TextView tv_next_pay; //下次付息日
    private TextView tv_zq_tender_surplus_time; //剩余期数
    private TextView tv_buy_money; //收购金额
    private TextView tv_tender_detail; //项目介绍
    private TextView tv_invest_record; //投资记录
    private EditText et_money;
    private Button bt_action; //竞拍


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tender_zq_invest);
        initView();
        initData();
    }

    @Override
    public void initView() {
        tv_common_title.setText("债权转让详情");
        tv_zq_people = (TextView) findViewById(R.id.tv_zq_people);
        tv_zq_tender_time = (TextView) findViewById(R.id.tv_zq_tender_time);
        tv_next_pay = (TextView) findViewById(R.id.tv_next_pay);
        tv_zq_tender_surplus_time = (TextView) findViewById(R.id.tv_zq_tender_surplus_time);
        tv_buy_money = (TextView) findViewById(R.id.tv_buy_money);
        tv_tender_detail = (TextView) findViewById(R.id.tv_tender_detail);
        tv_tender_detail.setOnClickListener(this);
        tv_invest_record = (TextView) findViewById(R.id.tv_invest_record);
        tv_invest_record.setOnClickListener(this);
        et_money = (EditText) findViewById(R.id.et_money);
        bt_action = (Button) findViewById(R.id.bt_action);
        bt_action.setOnClickListener(this);
    }

    @Override
    public void initData() {
//        requestLogin();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_tender_detail:
                gotoActivity(TenderDetailActivity.class);
                break;
            case R.id.tv_invest_record:
                gotoActivity(TenderRecordDetailActivity.class);
                break;
            case R.id.bt_action:
                gotoActivity(TenderInvestPwdActivity.class);
                break;
        }
    }

    String url = Constants.BASEURL + "myaccountApp/tRecordslist";

    //
    public void requestLogin() {
        HttpStringRequest request = new HttpStringRequest(Request.Method.POST, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                LogUtils.i(TenderZqInvestActivity.class,response);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                LogUtils.i(TenderZqInvestActivity.class,"code:"+error.networkResponse.statusCode);
            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> map = super.getHeaders();
                map.put("authorization", UserUtils.getUserInfo().token);
                return map;
            }

            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<>();
                map.put("page", "1");
                map.put("pagesize", "5");
                return map;
            }
        };
        request.setTag(url);
        requestQueue.add(request);
    }
}
